package com.huawei.gamebox;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import com.huawei.appmarket.R;
import com.huawei.appmarket.framework.activity.SecureActivity;
import com.huawei.appmarket.service.config.protocol.AppLaunchProtocol;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import o.azb;
import o.ced;
import o.cgv;
import o.cjk;
import o.cjm;
import o.dgm;
import o.diu;
import o.Logger;
import o.ContentManager;
import o.dzw;
import o.ll;

public class GameBoxActivity extends SecureActivity<AppLaunchProtocol> {
    private BroadcastReceiver ॱˊ = new SafeBroadcastReceiver(this) {
        final /* synthetic */ GameBoxActivity ˏ;

        {
            this.ˏ = r1;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            if (intent != null && !this.ˏ.isFinishing() && this.ˏ.ॱˊ().equals(intent.getStringExtra(this.ˏ.ॱˊ()))) {
                String action = intent.getAction();
                if ("com.huawei.appmarket.startup.flow.end".equals(action)) {
                    Logger.ˎ("GLOBAL_START_FLOW", "GameBoxActivity FLOW_END ");
                    this.ˏ.ॱॱ();
                } else if ("com.huawei.appmarket.startup.flow.interrupt".equals(action) || "com.huawei.appmarket.startup.flow.error".equals(action)) {
                    Logger.ˎ("GLOBAL_START_FLOW", "GameBoxActivity FLOW_INTERRUPT/FLOW_ERROR ");
                    this.ˏ.finish();
                }
            }
        }
    };

    private void ॱॱ() {
        ͺ();
    }

    private void ʼ() {
        Logger.ˎ("GLOBAL_START_FLOW", " registerBroadcast ");
        ll ˏ = ll.ˏ(ContentManager.getInstant().getContext());
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.huawei.appmarket.startup.flow.interrupt");
        intentFilter.addAction("com.huawei.appmarket.startup.flow.end");
        intentFilter.addAction("com.huawei.appmarket.startup.flow.error");
        ˏ.ˏ(this.ॱˊ, intentFilter);
    }

    private void ᐝ() {
        Logger.ˎ("GLOBAL_START_FLOW", " unregisterBroadcast ");
        ll.ˏ(getApplicationContext()).ˋ(this.ॱˊ);
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        cgv.ˋ(this, R.color.appgallery_color_appbar_bg, R.color.emui_white);
        getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.emui_white));
        dgm.ˋ(1, this);
        ˊॱ();
    }

    private String ॱˊ() {
        return "GameBoxActivity";
    }

    private void ˊॱ() {
        setRequestedOrientation(-1);
        if (dgm.isGameVSupport()) {
            ced.ˎ(getApplicationContext(), PackageUtils.HWGAMEBOX_PACKAGE_NAME, getString(R.string.gamebox_app_name));
            finish();
            return;
        }
        ʼ();
        setContentView(R.layout.activity_main);
        azb.ˏ(findViewById(R.id.hiapp_start_title_linearlayout));
        if (diu.ˊ().ˎ()) {
            Logger.ˎ("GLOBAL_START_FLOW", "not first startup");
            ॱॱ();
            return;
        }
        Logger.ˎ("GLOBAL_START_FLOW", "first startup");
        dzw.ॱ(this, ॱˊ());
    }

    public void onDestroy() {
        super.onDestroy();
        diu.ˊ().ˋ(this);
        ᐝ();
    }

    private void ͺ() {
        cjk.ˎ().ˋ(this, new cjm("gameboxmain.activity", null));
        finish();
    }
}
